package com.qtummatrix.controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.qtummatrix.entity.BlackList;
import com.qtummatrix.service.BlacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

@Controller("addBlacklist")
public class addBlacklistController extends ActionSupport implements ModelDriven<BlackList>{
	@Autowired
	private BlacklistService blacklistService;
	
	
	Map<String,Object> info=new HashMap<String, Object>();
	
	private BlackList blackList =new BlackList();
	public Map<String, Object> getInfo() {
		return info;
	}


	public void setInfo(Map<String, Object> info) {
		this.info = info;
	}


	public BlackList getModel() {
		
		return blackList;
	}
	public String addBlacklist() {
		String UID=blackList.getUID();
		String name=blackList.getName();
		String mark=blackList.getMark();
		String type=blackList.getType();
		String source=blackList.getSource();
		System.out.println(UID);
		System.out.println(name);
		System.out.println(mark);
		System.out.println(type);
		int count=blacklistService.addBlacklist(UID, name, mark, type, source);
		if(count>0) {
			info.put("message", "添加成功");
			return SUCCESS;
		}else {
			info.put("message", "添加失敗");
			return INPUT;
			
		}
		
	}
}
